<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>4.几个注意点</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <!-- 准备好一个容器-->
    <div id="demo">

    </div>
</body>

<script type="text/javascript">
    //阻止 vue 在启动时生成生产提示。
    Vue.config.productionTip = false
    //创建School组件
    const School = Vue.extend({
        name: 'MySchool',
        template: `
            <div>
                <h2>学校名称:{{name}}</h2>
                <h2>学校地址:{{address}}</h2>
                 <button @click = "welcome">点我欢迎你</button>
            </div>
            `,
            data(){
                return{
                    name:'尚硅谷',
                    address:'宏福科技园'
                }
            },
            methods: {
                welcome(){
                    alert(`你好啊!!欢迎来到${this.name}`)
                }
            },
    })
    const App = Vue.extend({
        components:{School},//注册组件
        template:`
        <div>
            <h2>********************</h2>
            <School/>
            <h2>********************</h2>
        </div>
        `,
       })
       new Vue({
            el:'#demo',
            components:{App},
            template:'<App></App>'
        })
</script>

</html>